<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片遮罩特效</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            padding: 50px;
        }
        li{
            list-style: none;
            width: 100px;
            height: 100px;
            background: lightcoral;
            float: left;
            margin-right: 10px;
            position: relative;
            overflow: hidden;
        }
        p{
            width: 100px;
            height: 30px;
            background: rgba(0,0,0,0.4);
            color: #fff;
            padding: 5px;
            box-sizing: border-box;
           position: absolute;
           bottom: -30px;
           left: 0;
        }
    </style>
</head>
<body>
    <ul id="box">
        <li>
            <p>遮罩1</p>
        </li>
        <li><p>遮罩2</p></li>
        <li><p>遮罩3</p></li>
    </ul>
</body>
<script src="./common.js"></script>
<script>
    /*
        图片遮罩特效
    */
    var box = document.getElementById('box');
    var lis = box.getElementsByTagName('li');//集合

    for(var i = 0; i < lis.length; i++) {
        //1.鼠标移入的时候遮罩出现
        lis[i].onmouseover = function() {
            //this:当前被触碰到那个对象 this：老子 opacity：0-100(封装的时候扩大方便计算)
            //children查找子节点，是一个集合的形式，通过下标定位某个子节点
            startMove(this.children[0],{'bottom' : 0});//渐现
            // console.log(this.children[0]);
        }
        //2.鼠标移开的时候遮罩隐藏
        lis[i].onmouseout = function() {
            //this:当前被触碰到那个对象 this：老子
            startMove(this.children[0],{'bottom' : -30});//渐隐
            // console.log(this.children[0]);
        }
    }

</script>
</html>